import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        shuju: [{
                // 订单信息
                end: "1/6",
                hotelId: "1",
                money: "85",
                roomId: "1",
                start: "1/6",
                sum: "1",
                thisTime: "2022-1-6 15:44",
                username: "张三一",
                usertel: "123",
                payOrno: false,
                hotelName: "",
                roomName: "",
                price: "",
                poto: "",
                xiaofei: "",
                adress: '',
                tuikuan: false
            },
            {
                // 订单信息
                end: "1/6",
                hotelId: "1",
                money: "116",
                roomId: "2",
                start: "1/6",
                sum: "1",
                thisTime: "2022-1-6 15:44",
                username: "李四",
                usertel: "2345",
                payOrno: true,
                hotelName: "",
                roomName: "",
                price: "",
                poto: "",
                xiaofei: "",
                adress: '',
                tuikuan: false
            },
            {
                // 订单信息
                end: "1/6",
                hotelId: "2",
                money: "116",
                roomId: "4",
                start: "1/6",
                sum: "1",
                thisTime: "2022-1-6 15:44",
                username: "李四",
                usertel: "2345",
                payOrno: true,
                hotelName: "",
                roomName: "",
                price: "",
                poto: "",
                xiaofei: "",
                adress: '',
                tuikuan: true
            },
        ]
    },
    mutations: {
        // 添加购物信息到全部
        addCart(state, pro) {
            state.shuju.push(pro)
        },
        // 从待付款移除商品
        removeCart(state, pro) {
            // 找到要移除商品的下标
            let index = state.shuju.findIndex(item => {
                    return item.roomId == pro.roomId
                })
                // 移除商品
            state.shuju.splice(index, 1)
        }
    },
    actions: {},
    modules: {}
})